/**
 * Copyright (c) 2025   All rights reserved.
 * <p>
 * https://www.sdl.io
 * <p>
 * 版权所有，侵权必究！
 */

package io.sdl.service.impl;

import io.sdl.common.service.impl.BaseServiceImpl;
import io.sdl.dao.SysDictDataDao;
import io.sdl.dao.SysDictTypeDao;
import io.sdl.dto.DictDTO;
import io.sdl.entity.SysDictDataEntity;
import io.sdl.service.SysDictDataService;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 字典类型
 *
 * @authorDc 1211734836@qq.com
 */
@Service
public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysDictDataEntity> implements SysDictDataService {

    private final SysDictTypeDao sysDictTypeDao;

    public SysDictDataServiceImpl(SysDictTypeDao sysDictTypeDao) {
        super();
        this.sysDictTypeDao = sysDictTypeDao;
    }

    @Override
    public List<String> getAllDictTypes() {


        return null;
    }

    @Override
    public List<DictDTO> getDictByType(String type) {
        return null;
    }

    @Override
    public DictDTO getDictValue(String type, String dictLabel) {
        return baseDao.getDictValue(type,dictLabel);
    }

    @Override
    public DictDTO getLabel(String type, String value) {
        return baseDao.getLabel(type,value);
    }


    @Override
    public Map<String, List<DictDTO>> getDictBatch(List<String> types) {


//        HashMap<String, List<DictDTO>> map = new HashMap<>();
        //根据类型获取对应的字典配置
        List<DictDTO> dictTypeList = sysDictTypeDao.getDictTypeList();

        HashMap<String, List<DictDTO>> collect = dictTypeList.stream().collect(Collectors.groupingBy(DictDTO::getDictType, HashMap::new, Collectors.toList()));
       /* types.forEach(type -> {


            map.put(type, dictTypeList);

        });*/

        return collect;
    }

}